<template>
<div>
	<content_top title="用户详情">
		<div slot="right" style="display: inline-block;float: right;margin-left:5px;">
			<Button @click="$router.back()"><Icon type="ios-arrow-back" size="16" style="margin-right:5px;" />返回</Button>
		</div>
	</content_top> 
    <div class="menu">
		<ul>
			<li class="cur"><a>用户详情</a></li>
			<li><a @click="$router.push({name:'user_info',params:{id:id}})">编辑资料</a></li>
			<li><a @click="$router.push({name:'user_log',params:{id:id}})">登录日志</a></li>
		</ul>
	</div>
	
	<div class="view_box">
		<div class="left_box">
			<img src="../../../assets/images/user_icon1.png">
			<h3 class="name">{{info.nickname}}</h3>
			<span class="bumen">{{info.bumen}}</span>
		</div>
		<div class="table">
			<table>
				<tr>
					<td class="title">员工编号</td>
					<td>{{info.username}}</td>
					<td class="title">合同单位</td>
					<td>{{info.company}}</td>
				</tr>
				<tr>
					<td class="title">中文名</td>
					<td>{{info.nickname}}</td>
					<td class="title">所属部门</td>
					<td>{{info.bumen}}</td>
				</tr>
				<tr>
					<td class="title">英文名</td>
					<td>{{info.en_name}}</td>
					<td class="title">所在地</td>
					<td>{{info.region}}</td>
				</tr>
				<tr>
					<td class="title">性别</td>
					<td>{{new Array('未知','男','女')[info.sex]}}</td>
					<td class="title">注册时间</td>
					<td>{{info.addtime}}</td>
				</tr>
				<tr>
					<td class="title">Email</td>
					<td>{{info.email}}</td>
					<td class="title">权限组</td>
					<td>{{info.group_name}}</td>
				</tr>
			</table>
		</div>
	</div>
	<div class="g_box view_box">
		<div class="g_head">
			<h3>其他资料（非必填）</h3>
		</div>
		<div class="g_box_con" style="padding: 30px 50px;width:100%;">
			<table>
				<tr>
					<td class="mtitle">职级</td>
					<td class="mtitle">手机号码</td>
					<td class="mtitle">直线/传真号码</td>
					<td class="mtitle">电话分机</td>
				</tr>
				<tr>
					<td align="center">{{info.rank}}</td>
					<td align="center">{{info.mobile}}</td>
					<td align="center">{{info.fax}}</td>
					<td align="center">{{info.phone}}</td>
				</tr>
			</table>
		</div>
	</div>
	
</div>
</template>

<script>
import company_list from '@/themes/components/company_list';
import bumen_list from '@/themes/components/bumen_list';
import region_list from '@/themes/components/region_list';


export default {
    name: 'admin_info',
	components:{
		company_list,
		region_list,
		bumen_list
	},
    data(){
        return {
            info:{
				username:'',
				nickname:'',
				en_name:'',
				sex:'0',
				company:'',
				bumen:'',
				group_name:'',
				region:'',
				rank:'',
				mobile:'',
				email:'',
				phone:'',
				password:'',
				confirm_password:'',
			},
			CheckRule:{
				username:[
					{ required: true, message: '请填写员工编号', trigger: 'blur' }
				],
				nickname:[
					{ required: true, message: '请填写中文名', trigger: 'blur' }
				],
				en_name:[
					{ required: true, message: '请填写英文名', trigger: 'blur' }
				],
				sex:[
					{ required: true, message: '请选择性别', trigger: 'blur' }
				],
				company:[
					{ required: true, message: '请选择合同单位', trigger: 'blur' }
				],
				bumen:[
					{ required: true, message: '请选择部门', trigger: 'blur' }
				],
				region:[
					{ required: true, message: '请选择地区', trigger: 'blur' }
				],
			},
			id:0
        };
    },
	created(){
		this.id = this.$route.params.id;
		this.load_data();
	},
    computed: {
       
    },
	methods:{
		load_data(){
			var self = this;
			var postdata = {
				id:this.id
			};
			
			Whttp.load('User/User/get_info',postdata,function(result){
				for(var i in result){
					self.info[i] = result[i];
				}
			});
		},
		handleSubmit(name) {
			this.$refs[name].validate((valid) => {
				if (valid) {
					this.save();
				}
			})
		},
		save(){
			var self = this;
			var postdata = this.info;
			postdata['id'] = this.id;
			
			Whttp.load('User/User/update',postdata,function(result){
				self.$Message.info('修改成功');
				
			});
		},
	}
};
</script>
<style scoped>
	@import './info.css';
</style>